//
//  GuideViewController.m
//  SHHCPhone
//
//  Created by sheng long on 14-7-1.
//  Copyright (c) 2014年 sheng long. All rights reserved.
//

#import "GuideViewController.h"
#import "TextFieldView.h"
#import "SelectPickerView.h"
#import "GuideRecordViewController.h"

@interface GuideViewController ()<SelectPickerViewDelegate>
{
    TextFieldView *field1;
}
@end

@implementation GuideViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    navigationBarView.title = @"简单指导";
    [navigationBarView setNormalLeftButton];
    
    field1 = [[TextFieldView alloc] init];
    [field1 setBgImage:@"输入框.png" titleImage:@"完善资料页-孕前体重icon" tip:@"输入你的体重"];
    [self.view addSubview:field1];
    [field1 setCenter:CGPointMake(self.view.frame.size.width/2, NAVIGATIONBAR_HEIGHT+34+field1.frame.size.height/2)];
    
    //体重
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setFrame:field1.frame];
    [self.view addSubview:button];
    [button addTarget:self action:@selector(selectTZ) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *doneButton = [OftenMenthod setButtonTitle:@"确定"];
    [self.view addSubview:doneButton];
    [doneButton addTarget:self action:@selector(doneButt) forControlEvents:UIControlEventTouchUpInside];
    [doneButton setCenter:CGPointMake(field1.center.x, field1.frame.size.height+field1.frame.origin.y+84+doneButton.frame.size.height/2)];
}

-(void)getSelectView:(NSInteger)type
{

}

-(void)selectTZ
{
    CLog(@"选择体重");
    NSString *text = nil;
    if (field1.textField.text.length==0) {
        text = [NSString stringWithFormat:@"50.0%@",APP_WEIGHT_UNIT];
    }else{
        text = field1.textField.text;
    }
    
    SelectPickerView *dateView = [[SelectPickerView alloc] initWithFrame:self.view.bounds];
    [dateView setDelegate:self];
    [dateView setShowView:YQTZ_TYPE text:text];
    [self.view addSubview:dateView];
}

-(void)doneButt
{
    if (field1.textField.text.length==0) {
        [LoadingFrameView autoDisappearTipview:@"请输入您的体重信息"];
    }else{
        GuideRecordViewController *vc = [[GuideRecordViewController alloc] init];
        vc.weight = [field1.textField.text stringByReplacingOccurrencesOfString:APP_WEIGHT_UNIT withString:@""];
        [self.navigationController pushViewController:vc animated:YES];
    }
}

#pragma mark - SelectPickerViewDelegate
//选择的时间
-(void)selectedText:(NSString*)text
{
    CLog(@"选中的=====%@",text);
    field1.textField.text = text;
}


@end
